<template>
  <div style="padding: 40px">


    <el-table :data="tableData" border stripe style="width: 100%;"  header-align="center" align="center">
      <el-table-column label="通知ID" width="70px"  header-align="center" align="center">
        <template slot-scope="scope">
          {{ (currentPage - 1) * pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column prop="courseName" label="课程名称"  header-align="center" align="center"/>
      <el-table-column prop="teacherName" label="老师姓名"  header-align="center" align="center"/>
      <el-table-column prop="clazzName" label="班级名称"  header-align="center" align="center"/>
      <el-table-column prop="credit" label="学分"  width="70px" header-align="center" align="center"/>
      <el-table-column prop="location" label="上课地点"    header-align="center" align="center"/>
      <el-table-column prop="startTime" label="开始时间(小节)"    header-align="center" align="center"/>
      <el-table-column prop="endTime" label="结束时间(小节)"  header-align="center" align="center"/>
      <el-table-column prop="remarks" label="备注" header-align="center" align="center" />
    </el-table>

    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-size="pageSize"
        layout="total,prev, pager, next, jumper"
        :total="total">
    </el-pagination>


  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import {getAllTC, getGuanUpDateDClass, getGuanXinStu, getStuGreadeAll} from '@/http/userList.js'
import {getGuanliStudentDelete} from "@/http/user";
import {getTeachUpload} from "@/http/minio";
import moment from "moment";

export default {
  name: "Notice",

  data() {
    return {
      form: {
        "courseName": "",
        "current": 0,
        "dayOfWeek": "",
        "pageSize": 0,
        "sortField": "",
        "sortOrder": "",
        "startTime": "",
        "endTime": "",
        "teacherName": ""
      },


      dialogVisible: false,
      dialogVisible1: false,
      dialogVisible2: false,
      currentPage: 1,
      pageSize: 10,
      total:0,
      tableData: [],

    }

  },
  created() {
    this.load()
  },

  methods: {



    async  handelChange(file, fileList){
      let formData =  new FormData()
      formData.append("data", file.raw);
      const res = await  getTeachUpload(formData)
      this.fileList =  [{name: 'food.jpg', url: res}]
    },
    async load() {
      const { code, message, data } = await getAllTC({current: this.currentPage, size: this.pageSize})
      console.log(data)
      this.tableData = data.records
      this.total= Number(data.total)

    },

    handleSizeChange(pageSize ) {
      this.pageSize = pageSize;
      this.currentPage = 1;
      this.load()
    },
    async handleCurrentChange(pageNum) {
      this.currentPage = pageNum
      const { code, message, data } = await getStuGreadeAll({ current: pageNum, size: this.pageSize })
      console.log(data)
      this.tableData = data.records
      this.total= Number(data.total)
      this.load(); // 重新加载数据
    },
    onDaloag(row) {
      this.form1 = row
      this.dialogVisible2 = true
    }
  },
  computed: {
    ...mapGetters({
      userRole: 'user/getUserRole'
    })
  }

}
</script>

<style></style>
